
{include file="public/header"/}

{include file="public/navleft" }
    <div class="tpl-content-wrapper">
 
<div class="layui-fluid" >
    <div class="layui-card">
      <div class="layui-card-body">
        <table id="demo" lay-filter="test"></table>
        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
              <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="getCheckData">获取选中行数据</button>
              <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="getCheckLength">获取选中数目</button>
              <button class="layui-btn layui-btn-sm layui-btn-normal" lay-event="isAll">验证是否全选</button>
            </div>
          </script>
           
          <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
          </script>
          
        <script>
            layui.use('table', function(){
              var table = layui.table;
              
              //第一个实例
              table.render({
                elem: '#demo'
                ,height: 542
                ,width:1104
                ,url: '/index.php/index/logs/logsData/' //数据接口
                ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
      title: '提示'
      ,layEvent: 'LAYTABLE_TIPS'
      ,icon: 'layui-icon-tips'
    }]
                ,page: true //开启分页
                ,cols: [[ //表头
                {type:'checkbox'}           
                  ,{field: 'id', title: 'ID', width:120, sort: true}
                  ,{field: 'user', title: '用户名', width:180}
                  ,{field: 'log', title: '记录', width:440, sort: true}
                  ,{field: 'createdate', title: '时间', width:280, sort: true}
        
                ]]
              });
              
            });
            </script>


  
  <script>
  layui.use('useradmin', layui.factory('useradmin')).use(['admin', 'useradmin', 'table'], function(){
    var $ = layui.$
    ,admin = layui.admin
    ,view = layui.view
    ,table = layui.table
    ,form = layui.form;
    
    form.render(null, 'layadmin-useradminrole-formlist');
    
    //搜索角色
    form.on('select(LAY-user-adminrole-type)', function(data){
      //执行重载
      table.reload('LAY-user-back-role', {
        where: {
          role: data.value
        }
      });
    });
  
    //事件
    var active = {
      batchdel: function(){
        var checkStatus = table.checkStatus('LAY-user-back-role')
        ,checkData = checkStatus.data; //得到选中的数据
  
        if(checkData.length === 0){
          return layer.msg('请选择数据');
        }
        
        layer.confirm('确定删除吗？', function(index) {
            
          //执行 Ajax 后重载
          /*
          admin.req({
            url: 'xxx'
            //,……
          });
          */
          table.reload('LAY-user-back-role');
          layer.msg('已删除');
        });
      },
      add: function(){
        admin.popup({
          title: '添加新角色'
          ,area: ['500px', '480px']
          ,id: 'LAY-popup-user-add'
          ,success: function(layero, index){
            view(this.id).render('user/administrators/roleform').done(function(){
              form.render(null, 'layuiadmin-form-role');
              
              //监听提交
              form.on('submit(LAY-user-role-submit)', function(data){
                var field = data.field; //获取提交的字段
  
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                //$.ajax({});
                layui.table.reload('LAY-user-back-role'); //重载表格
                layer.close(index); //执行关闭 
              });
            });
          }
        });
      }
    }  
    $('.layui-btn.layuiadmin-btn-role').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  });
  </script>










    </div>

</div>




{include file="public/footer"/}
